package code;

import java.util.Scanner;

public class QuestionNum_05_1 {
    public static void main(String[] args) {
        //1
        printSum();

        //2
        boolean result = isSame(3,9);
        System.out.println(result);

        //3
        compareNum();

        //4
        printMartix();

        //5
        printMultiplicationTable();
        //6
        calsqureArea(3,4);
        calCircleArea(2);


    }

    public static void printSum(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个小数:");
        double enterNum1 = sc.nextDouble();
        System.out.println("请输入一个整数:");
        int enterNum2 = sc.nextInt();
        double sum = enterNum1 + enterNum2;
        System.out.println("两数之和为:"+sum);
    }

    public static boolean isSame(int a,int b){
        return a==b;
    }

    public static void compareNum(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个小数:");
        double enterNum1 = sc.nextDouble();
        System.out.println("请输入一个整数:");
        int enterNum2 = sc.nextInt();
        if (enterNum1 > enterNum2) {
            System.out.println(enterNum1);
        }else {
            System.out.println(enterNum2);
        }
    }

    public static void printMartix(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入打印的行数:");
        int enterNum1 = sc.nextInt();
        System.out.println("请输入打印的列数:");
        int enterNum2 = sc.nextInt();
        for (int i=0;i<enterNum1;i++){
            for(int j=0;j<enterNum2;j++){
                System.out.print("*");
            }
            System.out.println("");
        }
    }

    public static void printMultiplicationTable(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入打印的行数:");
        int enterNum1 = sc.nextInt();
        for (int i=1;i<=enterNum1;i++){
            for(int j=1;j<=i;j++){
                int result = i * j;
                System.out.print(i+"*"+j+"="+result+" ");
            }
            System.out.println("");
        }

    }
    public static void calsqureArea(int a,int b){
        int area = a * b;
        System.out.println("长方形面积为:"+area);
    }
    public static void calCircleArea(double r){
        double area = 3.14 * r * r;
        System.out.println("圆形面积为:"+area);
    }
}
